<?php

namespace common\models\agreement;

use Yii;

/**
 * This is the model class for table "{{%agreement_context}}".
 *
 * @property int $id
 * @property int $parent_id 上级ID
 * @property string|null $title 标题
 * @property string|null $content 内容
 * @property int|null $listorder 序号
 * @property string|null $icon 图标
 * @property string|null $mark 备注
 * @property int $status 状态
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 * @property int $deleted_at 删除时间
 */
class AgreementContext extends \common\db\ActiveRecord {

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%agreement_context}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['parent_id', 'listorder', 'status', 'created_at', 'updated_at', 'deleted_at'], 'integer'],
            [['content'], 'string'],
            [['title', 'icon', 'mark'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'parent_id' => '上级ID',
            'title' => '标题',
            'content' => '内容',
            'listorder' => '序号',
            'icon' => '图标',
            'mark' => '备注',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
            'deleted_at' => '删除时间',
        ];
    }

    /**
     * @inheritdoc
     */
    public function getItems() {
        return $this->hasMany(static::class, ['parent_id' => 'id']);
    }

    /**
     * @inheritdoc
     */
    public function fields() {
        return [
            'id',
            'title',
            'content',
            'items',
        ];
    }

}
